<template>
    <div class="ff-recommend-list-home">
        <quantity
            :item="item"
        ></quantity>
        <div class="ff-recommend-list-home-prompt">
            <img :src="icon" alt="">
            <div behavior="scroll" loop="-1" scrollamount="5" height="38" class="ff-recommend-list-home-marquee">
                {{tip}}
            </div>
        </div>
        <router-view></router-view>
    </div>
</template>

<script>
    import quantity from '@/components/recommend/billingQuantity.vue'
    import confirmDialog from '@/components/dialog/confirmDialog.vue'
    import submitBar from '@/components/recommend/submitBar.vue'
    import laba from '@/assets/img/laba.png'

    export default {
        data() {
            return {
                item: [
                    {
                        label: '目标款数',
                        count: 0,
                        name: 'styCntTarget'
                    },
                    {
                        label: '现有款数',
                        count: 0,
                        name: 'styCntIn'
                    },
                    {
                        label: '在途款数',
                        count: 0,
                        url: '/recommendPassage',
                        name: 'styCntPurret'
                    },
                    {
                        label: '可补充款数',
                        count: 0,
                        name: 'styCntCan'
                    },
                    {
                        label: '已提交款数',
                        count: 0,
                        url: '/recommend/recommendSubmit',
                        name: 'styCntReq'
                    },
                    {
                        label: '可退仓款数',
                        count: 0,
                        name: 'styCntBak'
                    }
                ],
                dialog: {
                    visible: false,
                    title: '订单是否确认提交!',
                    close: true,
                    content: '',
                    cancelName: '取消',
                    confirmName: '确认'
                },
                icon: laba,
                tip: ''
            }
        },
        methods: {
            /*获取目标,在途这些数量*/
            getCountData () {
                this.$http({
                    url: '/api/SelPro/GetStrStysCnt',
                    method: 'post',
                    data: {
                        strId: this.$store.state.userId
                    }
                }).then(res => {
                    let data = res.data;
                    if(data.code === 1 && data.data) {
                        this.item.forEach(obj => {
                            this.$set(obj, 'count', data.data[obj.name])//obj.count = data.data[obj.name];
                        })
                    }
                })
            },
            /*获取首页顶部广播信息*/
            getindexTopTip () {
                this.$http({
                    url: '/api/SelPro/GetIndexNoticeTop',
                    method: 'post',
                    data: {
                        strId: this.$store.state.userId
                    }
                }).then(res => {
                    let data = res.data;
                    if(data.code === 1) {
                        this.tip = data.data && data.data[0] && data.data[0].content || '';
                    }
                })
            }
        },
        mounted () {
            this.getindexTopTip();
            this.getCountData();
        },
        components: {
            quantity,
            confirmDialog,
            submitBar
        },
        beforeRouteLeave (to, from, next) {
            //let obj = this.$route.matched.find(obj => obj.path === '/recommend/recommendDetails');
            //obj && obj.instances.default && this.$store.commit('recordLocation', obj.instances.default.$refs.recommendDetails.$refs.detailsBody.scrollTop);
            if(from.path === '/recommend') {
                this.$store.commit('recordLocation', document.documentElement.scrollTop);
            }
            next()
        },
    }
</script>

<style type="text/less" lang="less">
    @import "~@/assets/css/font.less";
    .ff-recommend-list-home {
        width: 100%;
        padding-bottom: 60px;
        position: relative;
        .cancel-all {
            margin-left: 42px;
            font-size: 14px;
            font-weight: 400;
            color: #333;
            cursor: pointer;
        }
        .ff-recommend-list-home-prompt {
            height: 36px;
            display: flex;
            align-items: center;
            box-sizing: border-box;
            background-color: #FFFBF0;
            padding-left: 12px;
            border: 1px solid @body-border-color;
            margin-bottom: 10px;
            img {
                margin-right: 13px;
                font-size: 18px;
                width: 18px;
                height: 18px;
            }
            .ff-recommend-list-home-marquee {
                color: #fd6442;
                line-height: 38px;
            }
        }
        .ff-recommend-list-bottom {
            box-sizing: border-box;
            position: fixed;
            bottom: 0;
            left: 50px;
            right: 50px;
            height: 50px;
            background-color: #F5F5F5;
            display: flex;
            align-items: center;
            justify-content: space-between;
            .ff-recommend-list-bottom--label {
                color: @body-common-font-color;
                font-size: 14px;
                margin-left: 12px;
                font-weight: 400;
            }
            .ff-recommend-list-total {
                font-size: 18px;
                color: @font-light-color;
                padding: 0 4px;
            }
            .ff-recommend-list-bottom--check {
                display: flex;
                align-items: center;
                label {
                    margin-left: 12px;
                }
            }
            .ff-recommend-list-bottom--right {
                .ff-recommend-list-bottom--label {
                    margin-right: 30px;
                }
            }
            .ff-recommend-list-submit {
                cursor: pointer;
                display: inline-block;
                line-height: 50px;
                box-sizing: border-box;
                background-color: @font-light-color;
                color: #fff;
                width: 140px;
                text-align: center;
                font-size: 16px;
            }
        }
    }
</style>
